{include file="common/mainHead"/}
<div class="admin-main fadeInUp animated">
    <blockquote class="layui-elem-quote">
        <a href="{:url('adminAdd')}" class="layui-btn layui-btn-small">
            <i class="fa fa-plus"></i> {:lang('add')}{:lang('admin')}
        </a>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>{:lang('admin')}{:lang('list')}</legend>
        <div class="layui-field-box table-responsive">
            <table class=" layui-table table-hover">
                <thead>
                <tr>
                    <th>{:lang('username')}</th>
                    <th>{:lang('email')}</th>
                    <th>{:lang('userGroup')}</th>
                    <th>{:lang('tel')}</th>
                    <th>{:lang('ip')}</th>
                    <th>{:lang('status')}</th>
                    <th>{:lang('action')}</th>
                </tr>
                </thead>
                <tbody>
                {volist name="adminList" id="v"}
                <tr>
                    <td>{$v.username}</td>
                    <td>{$v.email}</td>
                    <td>{$v.title}</td>
                    <td>{$v.tel}</td>
                    <td>{$v.ip}</td>
                    <td>
                        {if condition="$v['admin_id'] eq 1"}
                            <div>
                                <button disabled class="layui-btn layui-btn-mini layui-btn-disabled">{:lang('enabled')}</button>
                            </div>
                        {else /}
                        {if condition='$v["is_open"] eq 1'}
                        <a class="red" href="javascript:;" onclick="return stateyes('{$v.admin_id}');" title="{:lang('enabled')}">
                            <div id="zt{$v.admin_id}">
                                <button class="layui-btn layui-btn-warm layui-btn-mini">{:lang('enabled')}</button>
                            </div>
                        </a>
                        {else/}
                        <a class="red" href="javascript:;" onclick="return stateyes('{$v.admin_id}');" title="{:lang('disabled')}">
                            <div id="zt{$v.admin_id}">
                                <button class="layui-btn layui-btn-danger layui-btn-mini">{:lang('disabled')}</button>
                            </div>
                        </a>
                        {/if}
                        {/if}
                    </td>
                    <td>
                        <a href="{:url('adminEdit',['admin_id'=>$v['admin_id']])}" class="layui-btn layui-btn-mini">{:lang('edit')}</a>
                        {if condition="$v['admin_id'] eq 1"}
                        <a href="#" class="layui-btn layui-btn-mini layui-btn-disabled">{:lang('del')}</a>
                        {else /}
                        <a href="javascript:;" onclick="return del('{$v.admin_id}')" class="layui-btn layui-btn-mini layui-btn-danger">{:lang('del')}</a>
                        {/if}
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>

        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
            {$page}
        </div>
    </div>
</div>
{include file="common/mainFoot"/}
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form(), layer = layui.layer;
    });
    function del(id) {
        if (id == 1) {
            layer.msg('{:lang("Super administrator cannot be deleted")}', {time: 1800,icon:0});
            return false;
        }
        layer.confirm('{:lang("Are you sure you want to delete it")}', {icon: 3}, function (index) {
            window.location.href = "{:url('adminDel')}?admin_id="+id;
        });
    }
    function stateyes(id) {
        $.post('{:url("adminState")}',{'id': id},function (data) {
            if (data.status==1) {
                if (data.info == "{:lang('disabled')}") {
                    var a = '<button class="layui-btn layui-btn-danger layui-btn-mini">{:lang("disabled")}</button>'
                    $('#zt' + id).html(a);
                    return false;
                } else {
                    var b = '<button class="layui-btn layui-btn-warm layui-btn-mini">{:lang("enabled")}</button>'
                    $('#zt' + id).html(b);
                    return false;
                }
            }else{
                layer.msg(data.msg,{time:1000,icon:2});
                return false;
            }
        });
        return false;
    }
</script>